home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-07 / netusers.zip / SHOWDATA.C < prev    next >
Text File  |  1993-03-03  |  5KB  |  246 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. #include "nos.h"
  5. #include "noslib.h"
  6. #include "netusers.h"
  7. #include "proto.h"
  8.  
  9. extern struct serverdef *server;
  10. extern struct localuserlistdef *localuserlist;
  11. extern struct localuserlistdef *previous_localuserlist;
  12. extern struct localuserlistdef *startup_localuserlist;
  13.  
  14. extern int currentserver, adaptornum, numberoflogins, currentprinter, found;
  15. extern int userlistjobcount, printjobcount;
  16. extern int maxlocaluserlistcount, localuserlistcount;
  17. extern int monoflag, singleflag;
  18.  
  19.  
  20. void reportinfo ()
  21.     {
  22.     //report server name & time
  23.  
  24.     currentserver = 0;
  25.     while (currentserver < numberoflogins)
  26.     {
  27.     highlight ();
  28.     if (singleflag)
  29.         printf ("%-15s", server [currentserver] .servername);
  30.     else
  31.         cprintf ("%-15s", server [currentserver] .servername);
  32.  
  33.     nohighlight ();
  34.     if (singleflag)
  35.         {
  36.         printf ("%*s%02d/%02d/%04d %02d:%02d:%02d", 42,"",
  37.         server [currentserver] .time.TB_month,
  38.         server [currentserver] .time.TB_day,
  39.         server [currentserver] .time.TB_year,
  40.         server [currentserver] .time.TB_hour,
  41.         server [currentserver] .time.TB_minutes,
  42.         server [currentserver] .time.TB_seconds);
  43.         printf ("\r\n");
  44.         }
  45.     else
  46.         {
  47.         cprintf ("%*s%02d/%02d/%04d %02d:%02d:%02d", 42,"",
  48.         server [currentserver] .time.TB_month,
  49.         server [currentserver] .time.TB_day,
  50.         server [currentserver] .time.TB_year,
  51.         server [currentserver] .time.TB_hour,
  52.         server [currentserver] .time.TB_minutes,
  53.         server [currentserver] .time.TB_seconds);
  54.         cprintf ("\r\n");
  55.         }
  56.  
  57.     reportuserlist ();
  58.  
  59.     currentserver++;
  60.     }
  61.     }
  62.  
  63.  
  64.  
  65. void reportuserlist ()
  66.     {
  67.     //report each server's user list
  68.  
  69.     int linecount;
  70.  
  71.     printjobcount = 0;
  72.  
  73.     linecount = -1;
  74.     cprintf ("\r\n");
  75.  
  76.     while (printjobcount < localuserlistcount)
  77.     {
  78.     if (localuserlist [printjobcount] .server == currentserver)
  79.         {
  80.         if (++linecount == 3)
  81.         {
  82.         linecount = 0;
  83.         if (singleflag)
  84.             printf ("\r\n");
  85.         else
  86.             cprintf ("\r\n");
  87.         }
  88.  
  89.         highlight_active_machine ();
  90.  
  91.         if (singleflag)
  92.         printf ("%-25s ", localuserlist [printjobcount] .name_machine);
  93.         else
  94.         cprintf ("%-25s ", localuserlist [printjobcount] .name_machine);
  95.  
  96.         nohighlight ();
  97.         }
  98.     printjobcount++;
  99.     }
  100.  
  101.     if (singleflag)
  102.     {
  103.     printf ("\r\n");
  104.     printf ("\r\n");
  105.     }
  106.     else
  107.     {
  108.     cprintf ("\r\n");
  109.     cprintf ("\r\n");
  110.     }
  111.     }
  112.  
  113.  
  114. int getextch ()
  115.     {
  116.     //    gets value of extended key press
  117.  
  118.     int c;
  119.  
  120.     c = getch ();
  121.     if (c == 0)
  122.     {
  123.     c = getch ();
  124.     if (c < 128)
  125.         c += 128;
  126.     }
  127.     return (c);
  128.     }
  129.  
  130.  
  131. void highlight ()
  132.     {
  133.     //    sets colors for active servers
  134.  
  135.     if (!monoflag)
  136.     textcolor (BROWN);
  137.     highvideo ();
  138.     }
  139.  
  140.  
  141. void nohighlight ()
  142.     {
  143.     //    sets colors for server time & local users
  144.  
  145.     if (!monoflag)
  146.     textcolor (CYAN);
  147.     lowvideo ();
  148.     }
  149.  
  150.  
  151. void errorhighlight ()
  152.     {
  153.     //    sets colors for error messages
  154.  
  155.     if (!monoflag)
  156.     textcolor (RED);
  157.     highvideo ();
  158.     }
  159.  
  160.  
  161. void highlight_active_machine ()
  162.     {
  163.     //    sets colors for active users
  164.  
  165.     if (userrequest_since_startup () )
  166.     {
  167.     if (monoflag)
  168.         highvideo ();
  169.     else
  170.         {
  171.         textcolor (GREEN);
  172.         if (userrequest_since_update () )
  173.         highvideo ();
  174.         else
  175.         lowvideo ();
  176.         }
  177.     }
  178.     }
  179.  
  180.  
  181. int userrequest_since_startup ()
  182.     {
  183.     int i, j;
  184.  
  185.     for (i = 0; i < maxlocaluserlistcount; i++)
  186.     {
  187.     if ((strcmp (startup_localuserlist [i] .AUE_machine,
  188.          localuserlist [printjobcount] .AUE_machine) == 0) &&
  189.         (startup_localuserlist [i] .server ==
  190.          localuserlist [printjobcount] .server))
  191.         {
  192.         for (j = 0; j < 3; j++)
  193.         {
  194.         if (startup_localuserlist [i] .AUE_requests [j]  !=
  195.             localuserlist [printjobcount] .AUE_requests [j])
  196.             {
  197.             return true;
  198.             }
  199.         }
  200.         return false;
  201.         }
  202.     }
  203.  
  204.     return true;
  205.     }
  206.  
  207.  
  208. int userrequest_since_update ()
  209.     {
  210.     int i, j;
  211.  
  212.     for (i = 0; i < maxlocaluserlistcount; i++)
  213.     {
  214.     if ((strcmp (previous_localuserlist [i] .AUE_machine,
  215.          localuserlist [printjobcount] .AUE_machine) == 0) &&
  216.         (previous_localuserlist [i] .server ==
  217.          localuserlist [printjobcount] .server))
  218.         {
  219.         for (j = 0; j < 3; j++)
  220.         {
  221.         if (previous_localuserlist [i] .AUE_requests [j]  !=
  222.             localuserlist [printjobcount] .AUE_requests [j])
  223.             {
  224.             return true;
  225.             }
  226.         }
  227.         return false;
  228.         }
  229.     }
  230.  
  231.     return true;
  232.     }
  233.  
  234. void message (char *messagetext, int eraseflag)
  235.     {
  236.     //    displays message in center of the first line of the screen
  237.  
  238.     gotoxy ( (40 - (strlen (messagetext) / 2) ), 1);
  239.     errorhighlight ();
  240.     cprintf ("%s", messagetext);
  241.     nohighlight ();
  242.  
  243.     if (eraseflag == true)
  244.     sleep (3);
  245.     }
  246.